<template>
    <div>
        <avue-crud :option="{...row.option,menu:false,selection:false,header:false,height:'auto'}"
                   :table-loading="loading"
                   :data="tableData"
                   @current-change="currentChange"
                   @size-change="sizeChange"
                   ref="crud"
                   :page.sync="page">
        </avue-crud>
    </div>
</template>

<script>
import {request} from "axios";

export default {
    name: "commonHistory",
    data() {
        return {
            tableData: [],
            loading: false,
            page: {
                pageSize: 10,
                currentPage: 1,
                total: 1
            },

            row: {}
        }
    },
    methods: {
        currentChange(currentPage) {
            this.page.currentPage = currentPage;
            this.getList();
        },
        sizeChange(pageSize) {
            this.page.pageSize = pageSize;
            this.getList();
        },

        getList() {
            let obj = {};
            let row = this.row;
            obj[row.requestDataType] = {
                ...row.params_,
                page: this.page.currentPage,
                pageSize: this.page.pageSize,
            }
            request({url: row.url, method: row.method, ...obj}).then(res => {
                const {totalRows, list} = res.data.data;
                this.tableData = list;
                console.log('this.tableData',this.tableData)
                this.page.total = totalRows;
            })
        },
        show(row) {
            console.log('row',row)
            this.row = row;
            this.getList();
        }
    },
}
</script>

<style scoped lang="scss">

</style>
